package january.test_1_29;

import java.util.Scanner;

public class TestMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String[] arr = new String[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.next();
        }
        Boolean a = A(arr);
        Boolean b = B(arr);
        if(a && b) {
            System.out.println("both");
            return;
        }
        if(a) {
            System.out.println("lexicographically");
            return;
        }
        if(b) {
            System.out.println("lengths");
            return;
        }
        System.out.println("none");
    }
    public static Boolean A(String[] arr) {
        int tmp = 0;
        for(int i = 1; i < arr.length; i++) {
            if(arr[i-1].length() <= arr[i].length()) {
                for(int j = 0; j < arr[i-1].length(); j++) {
                    if(arr[i-1].charAt(j) > arr[i].charAt(j)) {
                        return false;
                    }
                }
            } else {
                for(int j = 0; j < arr[i].length(); j++) {
                    if(arr[i-1].charAt(j) < arr[i].charAt(j)) {
                        tmp = 1;
                        break;
                    }
                }
                if (tmp == 0) {
                    return false;
                }
                tmp = 0;
            }

        }
        return true;
    }
    public static Boolean B(String[] arr) {
        for(int i = 1; i < arr.length; i++) {
            if(arr[i].length() < arr[i-1].length()) {
                return false;
            }
        }
        return true;
    }
}
